package com.lgx.mall.business.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.lgx.common.web.Constants;
import com.lgx.common.web.Pagination;
import com.lgx.common.web.json.Json2Utils;
import com.lgx.mall.business.service.IRedateService;

@Controller
@RequestMapping("/redate")
public class RedateController {
	
	@Autowired
	private IRedateService redateService;

	public IRedateService getRedateService() {
		return redateService;
	}

	public void setRedateService(IRedateService redateService) {
		this.redateService = redateService;
	}
	
	
	@RequestMapping("/redateMgr.do")
	public String redateMgr(HttpServletRequest request,HttpServletResponse response){
		return "/mall/business/rebate/rebateMgr";
	}
	
	
	@RequestMapping("/list.do")
	public void list(HttpServletRequest request,HttpServletResponse response){
		//接受必要参数
		String timeStart = request.getParameter("timeStart");
		String timeEnd = request.getParameter("timeEnd");
		
		String pageNum = request.getParameter("page");
		String pageSize= request.getParameter("rows");
		if(StringUtils.isEmpty(pageSize))pageSize = Constants.PAGE_SIZE;
		if(StringUtils.isEmpty(pageNum))pageNum = Constants.FIRST_PAGE_NUM;
		
		Pagination page = this.redateService.findRebatePagination(timeStart, timeEnd, Integer.parseInt(pageSize), Integer.parseInt(pageNum));
		
		Json2Utils.parseJSON(page, response);
	}
	
	
	

}
